function [rx] = crossmat(r)
% [Rx] = CROSSMAT( R )
%  Construct the 3x3 matrix equivalent of the 3D vector cross product
%  operation.
%
%  R x V = cross(R,V) = [Rx] * V
%
%  where R and V are 1D or 2D arrays of 3 elements (vectors, usually 3x1)
%  and Rx is the necessary arrangement of R1 elements into a 3x3 matrix.
%
%       [   0   , -R(3) ,   R(2) ]
%  Rx = [  R(3) ,   0   ,  -R(1) ]
%       [ -R(2) ,  R(1) ,    0   ]
%
%
if isvector(r) ~= 1
    error('in CROSSMAT, input is not a vector.');
end

if max(size(r)) ~= 3
    error('in CROSSMAT, input vector must have exactly 3 elements.');
end

rx = [0 -r(3) r(2); r(3) 0 -r(1); -r(2) r(1) 0];

